//
//  CZMainViewController.swift
//  CZWeibo007
//
//  Created by Vize on 15/12/24.
//  Copyright © 2015年 Vize. All rights reserved.
//

import UIKit

class CZMainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        let mainTabbar = CZMainTabbar()
        setValue(mainTabbar, forKey: "tabBar")

        self.tabBar.tintColor = UIColor.orangeColor()
        let homeVC = CZHomeViewController()
        
        homeVC.title = "首页"
        self.addChildVC(homeVC, title: "首页", imageName: "tabbar_home")
        
        let MesssageVC = CZMessageViewController()
        self.addChildVC(MesssageVC, title: "信息", imageName: "tabbar_message_center")
        
        let DiscoveryVC = CZDiscoveryViewController()
        self.addChildVC(DiscoveryVC, title: "发现", imageName: "tabbar_discover")
        
        let ProfileVC = CZProfileViewController()
        self.addChildVC(ProfileVC, title: "我", imageName: "tabbar_profile")
        
        // Do any additional setup after loading the view.
    }

    
    private func addChildVC(controller: UIViewController, title: String, imageName: String) {
        
        self.addChildViewController(UINavigationController(rootViewController: controller))
        controller.title = title
        controller.tabBarItem.image = UIImage(named: imageName)
        
        let highLightedName = imageName + "_highlighted"
//        controller.tabBarItem.selectedImage = UIImage(named: highLightedName)?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
//        controller.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName :UIColor.orangeColor()], forState: UIControlState.Selected)
   
    }
    
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
